home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / dfpp01.zip / TEXTBOX.H < prev    next >
C/C++ Source or Header  |  1992-11-11  |  3KB  |  87 lines

  1. // ------------- textbox.h
  2.  
  3. #ifndef TEXTBOX_H
  4. #define TEXTBOX_H
  5.  
  6. #include "control.h"
  7.  
  8. const int SHORTCUTCHAR = '~';
  9. const int InitialBufferSize = 1024;
  10.  
  11. class ScrollBar;
  12.  
  13. class TextBox : public Control    {
  14.     ScrollBar *hscrollbar;  // horizontal scroll bar
  15.     ScrollBar *vscrollbar;  // vertical scroll bar
  16.     unsigned *TextPointers; // -> list of line offsets
  17.     Bool resetscrollbox;
  18. protected:
  19.     // ---- text buffer
  20.     String *text;           // window text
  21.     unsigned int bufflen;   // length of buffer
  22.     int wlines;             // number of lines of text
  23.     unsigned int textlen;   // text length
  24.     int textwidth;          // width of longest line in textbox
  25.     // ---- text display
  26.     int wtop;               // text line on top of display
  27.     int wleft;              // left position in window viewport
  28.     int BlkBegLine;         // beginning line of marked block
  29.     int BlkBegCol;          // beginning column of marked block
  30.     int BlkEndLine;         // ending line of marked block
  31.     int BlkEndCol;          // ending column of marked block
  32.     int shortcutfg;         // shortcut key color
  33.     char *TextLine(int line)
  34.         { return (char *)(*text) + *(TextPointers+line); }
  35.     int DisplayShortcutField(
  36.         String sc, int x, int y, int fg, int bg);
  37.     void WriteShortcutLine(int lno, int fg, int bg);
  38.     void WriteTextLine(int lno, int fg, int bg);
  39.     void BuildTextPointers();
  40.     void SetScrollBoxes();
  41.     virtual void SetColors();
  42. public:
  43.     TextBox(char *ttl,int lf,int tp,int ht,int wd,DFWindow *par)
  44.                         : Control(ttl, lf, tp, ht, wd, par)
  45.             { OpenWindow(); }
  46.     TextBox(char *ttl, int ht, int wd, DFWindow *par)
  47.                         : Control(ttl, ht, wd, par)
  48.             { OpenWindow(); }
  49.     TextBox(int lf, int tp, int ht, int wd, DFWindow *par)
  50.                         : Control(lf, tp, ht, wd, par)
  51.             { OpenWindow(); }
  52.     TextBox(int ht, int wd, DFWindow *par) : Control(ht,wd,par)
  53.             { OpenWindow(); }
  54.     TextBox(char *ttl)    : Control(ttl)
  55.             { OpenWindow(); }
  56.     virtual ~TextBox()
  57.         { if (windowstate != CLOSED) CloseWindow(); }
  58.     // -------- textbox API messages
  59.     virtual void ScrollUp();
  60.     virtual void ScrollDown();
  61.     virtual void ScrollRight();
  62.     virtual void ScrollLeft();
  63.     virtual void PageUp();
  64.     virtual void PageDown();
  65.     virtual void PageRight();
  66.     virtual void PageLeft();
  67.     virtual void Home();
  68.     virtual void End();
  69.     virtual void OpenWindow();
  70.     virtual void CloseWindow();
  71.     virtual void AddText(char *txt);
  72.     virtual void SetText(char *txt);
  73.     virtual void SetTextLength(unsigned int len);
  74.     virtual void ClearText();
  75.     virtual void Show();
  76.     virtual void Paint();
  77.     virtual void Keyboard(int key);
  78.     String ExtractTextLine(int lno);
  79.     void ClearTextBlock()
  80.         { BlkBegLine=BlkEndLine=BlkBegCol=BlkEndCol=0; }
  81.     void HorizontalPagePosition(int pct);
  82.     void VerticalPagePosition(int pct);
  83. };
  84.  
  85. #endif
  86.  
  87.